<template>
    <div class="mui-content">
		<div id="slider" class="mui-slider">
			<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
				<div class="mui-scroll">
					<a v-for="item in data" :key="item.id" :class="['mui-control-item',item.id == 0 ? 'mui-active' : '']" href="/home" data-wid="tab-top-subpage-1.html" @click="getList(item.id)">
						{{item.title}}
					</a>
				</div>
			</div>
		</div>
		<div class="itContent">	
			<ul>
				<router-link tag="li" :to="'/home/imageTextShow/' + item.id" v-for="item in list" :key="item.id">
					<img v-lazy="item.img_url">
					<h4>{{item.title}}</h4>
				</router-link>
			</ul>
		</div>
	</div>
</template>
<script>
import mui from '../../lib/mui/js/mui.min.js'
import {Toast} from 'mint-ui'
export default {
    data(){
		return {
			data:{},
			list:{}
		}
	},
	mounted(){//如果要操作元素最好在mounted里
		mui('.mui-scroll-wrapper').scroll({
			deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
		});
	},
	created(){
		this.getData()
		this.getList(0)
	},
	methods:{
		getData (){
			var that = this
			this.$http.get(this.base_url+'vue/datas/imageText/header.json','json').then(function(data){
				if(status==0){
					data.body.data.unshift({"id":0,"title":"全部"})
					that.data = data.body.data
				}else{
					Toast("加载失败")
				} 
			})
		},
		getList (id){
			this.$http.get(this.base_url+'vue/datas/imageText/imgT.json','json').then(function(data){
				if(status==0){ 
					this.list = data.body.data[id]
				}else{
					Toast("加载失败")
				}
			})
		}
	}
}
</script>
<style scoped>
*{
	touch-action: pan-y
}
.itContent img[lazy=loaded] {
	width: 100%;
	margin: auto;
	vertical-align: middle;
	box-shadow: 0 0 4px red;
}
.itContent{
	background: #fff;
	padding-bottom: 52px;
}
.itContent ul{
	margin: 0;
	padding: 2%;
}
.itContent li{
	list-style: none;
	position: relative;
	margin-bottom: 4% ;
}
.itContent li h4{
	bottom: 0;
	position: absolute;
}
.my-gallery>figure{
	margin: 0;
}
</style>


